package study.couse04;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class UseFutureTask {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> ft = new FutureTask<>(new FutureSub() );
        Thread th = new Thread(ft);
        th.start();;
        Integer res = ft.get();
        System.out.println("子线程结果:"+res);
    }
    static class FutureSub implements Callable<Integer > {

        @Override
        public Integer call() throws Exception {
            Thread.sleep(100);
            return 1;
        }
    }

}
